﻿using System;
using System.Collections.Generic;

namespace UsersSettingsTool.Options
{
    public class Currency
    {
        private sealed class ValueEqualityComparer : IEqualityComparer<Currency>
        {
            public bool Equals(Currency x, Currency y)
            {
                if (ReferenceEquals(x, y)) return true;
                if (ReferenceEquals(x, null)) return false;
                if (ReferenceEquals(y, null)) return false;
                if (x.GetType() != y.GetType()) return false;
                return string.Equals(x.Value, y.Value);
            }

            public int GetHashCode(Currency obj)
            {
                return (obj.Value.GetHashCode());
            }
        }

        private static readonly IEqualityComparer<Currency> ValueComparerInstance = new ValueEqualityComparer();

        public static IEqualityComparer<Currency> ValueComparer
        {
            get { return ValueComparerInstance; }
        }

        public Currency(string text, Guid value)
        {
            Text = text;
            Value = value;
        }

        public Currency()
        {
            Text = string.Empty;
            Value = Guid.Empty;
        }

        public string Text { get; set; }
        public Guid Value { get; set; }
    }
}
